<?php

require("../function/util.php");

$content_id 			= $_POST['content_id'];

$content_text 			= addslashes($_POST['content_text']);

$err_msg = "";

if (strlen(trim($content_text)) == 0) {
    $err_msg .= "Please fill in Text<br/>";
}

if (strlen($err_msg) == 0) 
{
	$sql = "UPDATE content
			SET content_text ='$content_text'
			WHERE content_id = '$content_id'";
	if(runSQL($sql))
	{

?>
		<script type="text/javascript">
			alert("Edit Content Successful!");
				top.document.getElementById('cancel_button').click();
		</script>
<?php
	} else
	{
?>
		<script type="text/javascript">
			alert("Edit Content can't not be performed right now!");
		</script>
<?php
	}
} else
{
?>
    <script type="text/javascript">
        top.document.getElementById('error').innerHTML = "<?= $err_msg ?>";
    </script>
<?php
}
?>